﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Edit.ascx.cs" Inherits="Modules_Content_Edit" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:PlaceHolder runat="server" ID="phContent">
    <table class="Form">
        <tr>
            <td style="width: 15%">Chọn book
            </td>
            <td>
                <select id="books" runat="server" style="width: 565px;">
                </select>
                <input type="text" id="bookSearch" placeholder="Tìm theo tên truyện + Enter" disabled="disabled"
                    value="" style="width: 250px;" />
                <asp:Button runat="server" ID="btnNextFromCurrent" Text="Đến chương tiếp theo" OnClick="OnNextCurrent" />
            </td>
        </tr>
        <tr>
            <td style="width: 15%">Chương <span class="red bold">(*)</span>
            </td>
            <td>
                <asp:TextBox ID="Chapter" runat="server" Width="100"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 15%">Tiêu đề
            </td>
            <td>
                <asp:TextBox ID="Title" runat="server" Width="60%"></asp:TextBox>
                <a target="_blank" href="<%=PublishLink %>">Xem thử</a>
            </td>
        </tr>
        <tr>
            <td>SafeName
            </td>
            <td>
                <asp:TextBox ID="SafeName" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>Nội dung <span class="red bold">(*)</span>
            </td>
            <td>
                <telerik:RadEditor ID="Body" runat="server" ToolsFile="~/cms_client/Editor_Rad_Full.xml"
                    Height="500" Width="99%">
                </telerik:RadEditor>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <asp:CheckBox ID="Broken" runat="server" Text="Hỏng nội dung"></asp:CheckBox>
                <asp:Button ID="btnReCrawlOnline" runat="server" Text="Thử lấy lại nội dung online" OnClick="OnTryCrawl" />
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <asp:CheckBox ID="IsExtens" runat="server" Text="Là ngoại truyện"></asp:CheckBox>
                <em>(Nếu là ngoại truyện hoặc chương thêm vào thì hãy chọn)</em>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <hr />
            </td>
        </tr>
        <tr>
            <td>CrawlName
            </td>
            <td>
                <asp:TextBox ID="CrawlName" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>CrawlUrl
            </td>
            <td>
                <asp:TextBox ID="CrawlUrl" runat="server"></asp:TextBox>
            </td>
        </tr>
    </table>
    <br class="clear" />
    <asp:Button ID="Save" CssClass="CommandButton" runat="server" Text="Lưu lại" Width="120" ValidationGroup="NEW"
        OnClick="Save_Click" OnClientClick="return checkValid();" />
    <asp:Button ID="Cancel" runat="server" CssClass="CommandButton" OnClick="Cancel_Click"
        Text="Bỏ qua" ValidationGroup="xxxx" />
    <asp:Button ID="Delete" runat="server" CssClass="CommandDelete" OnClick="Delete_Click"
        OnClientClick="return confirmDelete();" ValidationGroup="xxxx" ToolTip=" Xóa " />    
    <br class="clear" />
    <br class="clear" />
    <input type="button" class="CommandButton" id="btnReCrawlFromChap" value="Update lại từ chương này" style="width: 180px;margin-left: 0;"/>
    <div id="msgShow"></div>
</asp:PlaceHolder>
<script type="text/javascript">
    function checkValid() {
        var book = jQuery('#<%=books.ClientID %>');
        if (book.val() == null) {
            alert("Hãy chọn 1 quyển truyện!");
            book.focus();
            return false;
        }
        var chapter = jQuery('#<%=Chapter.ClientID %>');
        if (!jQuery.isNumeric(chapter.val())) {
            chapter.val('');
            alert("Hãy điền số chương!");
            chapter.focus();
            return false;
        }
        var title = jQuery('#<%=Title.ClientID %>');
        if (title.val().length == 0) {
            alert("Thiếu tiêu đề!");
            title.focus();
            return false;
        }
        return true;
    }
    jQuery(function ($) {
        $('#btnReCrawlFromChap').click(function () {
            var id = '<%=Request["Id"]%>';
            loading(true, '#msgShow');
            $.ajax({
                url: '/Ajax.aspx',
                dataType: 'json',
                data: {
                    p: 'Content',
                    act: 'reCrawlFromChap',
                    cid: id
                },
                success: function (data) {
                    loading(false, '#msgShow');
                    $('#msgShow').html(data);
                },
                error: function (data) { loading(false, '#msgShow'); $('#msgShow').html(data); }
            });
        });
    });
</script>
